package my.jwds.p69;

public class MySqrt {


    public static void main(String[] args) {
        MySqrt o = new MySqrt();
        System.out.println(o.mySqrt(2147395599));
    }

    public int mySqrt(int x) {
        int l = 0,r = x,res =0;
        while(l <= r){
            int mid = (l+r)/2;
            if ((long)mid * mid <= x){
                res = mid;
                l = mid +1;
            }else{
                r = mid -1;
            }
        }
        return res;
    }
}
